

#include "DBPetHandler.h"
#include "GamePlayer.h"

#include "CreatureManager.h"
#include "ExpConfig.h"


// fvoid		DB_Select_Pet( dbResult* result )
// {
// 	if ( !result )
// 		return;
// 	
// 	GamePlayer* player = static_cast< GamePlayer* >( result->pData );
// 	if ( player == F_NULL )
// 		return;
// 	
// 	if ( !player->IsValid() )
// 		return;
// 	
// 	dbIRecordset* pRes =  result->pResult;
// 	dbIRecord* tempRecord = F_NULL;
// 	
// 	if( !pRes )
// 		return;
// 	
// 	GamePetMap& petMap = player->GetPetMap();
// 	
// 	if ( !petMap.empty() )
// 	{
// 		assert( 0 );
// 		return;
// 	}
// 	
// 	fint32 RecordCount = pRes->CountRecord();
// 	
// 	for ( fint32 i = 0 ; i < RecordCount ; i++ )
// 	{
// 		pRes->Move(0);
// 		
// 		tempRecord = pRes->GetRecord();
// 		
// 		fint32 petID = tempRecord->Field( (fuint32)0 );
// 		
// 		STRCPY( SQL_BUFFER , tempRecord->Field( 1 ) );
// 		SQL_BUFFER[ MAX_SQL_BUFFER - 1 ] = '\0';
// 		
// 		fint32 type = atoi( SQL_BUFFER );
// 		char* pc = strchr( SQL_BUFFER , ',' );pc++;
// 		
// 		fint32 id = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		
// 		GameEnemy* enemy = gCreatureManager->GetEnemy( id );
// 		GamePet& pet = petMap[ id ];
// 		pet.Init( enemy );
// 		
// 		CreatureData& data = petMap[ id ].GetData();
// 		data.Gender = pet.GetGender();
// 		data.Level = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.EXP = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.LevelUpPoint = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.Vitality = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.Strength = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.Toughness = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.Dexterity = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.Charm = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.HP = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		data.MP = atoi( SQL_BUFFER );
// 		pc = strchr( SQL_BUFFER , ',' );pc++;
// 		
// 		data.HP = data.MAXHP = GETMAXHP( data.Vitality , data.Strength , data.Toughness , data.Dexterity );
// 		data.NEXTEXP = gExpManager->EXP[ data.Level + 1 ];
// 		
// 	}
// }


fvoid		DB_Creat_Pet( dbResult* result )
{
	if ( !result )
		return;

	GamePlayer* player = static_cast< GamePlayer* >( result->pData );
	if ( player == F_NULL )
		return;

	if ( !player->IsValid() )
		return;

	dbIRecordset* pRes =  result->pResult;
	dbIRecord* tempRecord = F_NULL;

	if( !pRes )
		return;

	pRes->Move(0);
	tempRecord = pRes->GetRecord();

	fint32 petID = tempRecord->Field( (fuint32)0 );

	
}


fvoid		DB_Delete_Pet( dbResult* result )
{
	if ( !result )
		return;

	GamePlayer* player = static_cast< GamePlayer* >( result->pData );
	if ( player == F_NULL )
		return;

	if ( !player->IsValid() )
		return;

	dbIRecordset* pRes =  result->pResult;
	dbIRecord* tempRecord = F_NULL;

	if( !pRes )
		return;

	pRes->Move(0);
	tempRecord = pRes->GetRecord();

	fint32 petID = tempRecord->Field( (fuint32)0 );

	
}
